package com.szy.redstonemcu;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;

public class GuiProxy implements IGuiHandler {

    public static GuiProxy instance=new GuiProxy();
    public static GuiProxy getInstance(){
        return instance;
    }
    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
        BlockPos pos = new BlockPos(x, y, z);
        TileEntity te = world.getTileEntity(pos);
        if (te instanceof McuBaseEntity) {
            return new RM8FAA_Container(player.inventory, (McuBaseEntity) te);
        }
        return null;
    }

    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
        BlockPos pos = new BlockPos(x, y, z);
        TileEntity te = world.getTileEntity(pos);
        if (te instanceof McuBaseEntity) {
            McuBaseEntity containerTileEntity = (McuBaseEntity) te;
            return new RM8FAA_ContainerGUI(player.inventory, containerTileEntity);
        }
        return null;
    }
}